package simulation;

/**
 * This class represents a Muscle in the simulation.
 * 
 */
public class Muscle extends Spring {
    private static final double FREQUENCY = 10;
    private double myAmplitude;

    /**
     * Creates a muscle with two masses, rest length, spring constant, and
     * amplitude of harmonic motion.
     */
    public Muscle (Mass start, Mass end, double length, double kVal, double amplitude) {
        super(start, end, length, kVal);
        myAmplitude = amplitude;
    }

    /**
     * Changes length with the harmonic motion of Muscles.
     */
    @Override
    protected double getLength (double elapsedTime) {
        double length = super.getLength(elapsedTime);
        return length * (1 + myAmplitude * Math.sin(FREQUENCY * elapsedTime));
    }

}
